<html>
<head><meta charset="utf-8"><title>Byte-shuffles · project-portable-simd · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/index.html">project-portable-simd</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Byte-shuffles.html">Byte-shuffles</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="240958438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Byte-shuffles/near/240958438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Byte-shuffles.html#240958438">(Jun 01 2021 at 15:22)</a>:</h4>
<p>So in <a href="https://github.com/rust-lang/stdsimd/issues/106#issuecomment-851881475">https://github.com/rust-lang/stdsimd/issues/106#issuecomment-851881475</a> I realized that we actually probably do want to have a specialized byte shuffle function, per the reasoning there: we don't want to do a byteswap, therefore we don't want to cast to NE bytes and risk having the same shuffle indices point to different bytes based on endianness.</p>



<a name="240958835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Byte-shuffles/near/240958835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Byte-shuffles.html#240958835">(Jun 01 2021 at 15:24)</a>:</h4>
<p>I was kind of thinking that if you want to do a byte shuffle, you just need to account for whatever endianness you're using.  If you want to have a portable byte shuffle you need to use <code>to_{le,be}_bytes</code> (which we will eventually have)</p>



<a name="240958891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Byte-shuffles/near/240958891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Byte-shuffles.html#240958891">(Jun 01 2021 at 15:25)</a>:</h4>
<p>That winds up doing a byteswap tho'.</p>



<a name="240958980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Byte-shuffles/near/240958980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Byte-shuffles.html#240958980">(Jun 01 2021 at 15:25)</a>:</h4>
<p>I would be shocked if llvm doesn't combine the byte swap and the shuffle since they're both just shuffles</p>



<a name="240959113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Byte-shuffles/near/240959113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Byte-shuffles.html#240959113">(Jun 01 2021 at 15:26)</a>:</h4>
<p>LLVM has to do very specific things to handle big-endian vectors on Neon. I am prepared to be shocked. <a href="https://llvm.org/docs/BigEndianNEON.html#id10">https://llvm.org/docs/BigEndianNEON.html#id10</a></p>



<a name="240959382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Byte-shuffles/near/240959382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Byte-shuffles.html#240959382">(Jun 01 2021 at 15:28)</a>:</h4>
<p>Right but the byte swap itself is just a shuffle (and it's the same shuffle regardless of endianness)</p>



<a name="240959554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Byte-shuffles/near/240959554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Byte-shuffles.html#240959554">(Jun 01 2021 at 15:29)</a>:</h4>
<p>As far as optimization goes it will just be merging two <code>vtbl</code> into one, or something similar</p>



<a name="240959713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Byte-shuffles/near/240959713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Byte-shuffles.html#240959713">(Jun 01 2021 at 15:30)</a>:</h4>
<p>I'd like to see proof that LLVM generates bad asm</p>



<a name="240960841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Byte-shuffles/near/240960841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Byte-shuffles.html#240960841">(Jun 01 2021 at 15:38)</a>:</h4>
<p>hmm.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>